package com.ljkj.blockpay.widget;

import android.content.Context;
import android.view.View;

import com.ljkj.blockpay.R;

/**
 * Created by tianping on 2020/1/3.
 * 自定义加载动效
 */
public class LoadingDialog {
    private CommonDialog commonDialog;
    private Context context;

    public LoadingDialog(Builder builder) {
        commonDialog = builder.commonDialog;
        context = builder.context;
    }

    public void dismiss() {
        DYLoadingView dyload = this.commonDialog.findViewById(R.id.dy);
        dyload.stop();
        commonDialog.dismiss();
    }

    public void show() {
        commonDialog.show();
    }

    public static class Builder {
        private Context context;
        private CommonDialog commonDialog;


        public Builder(Context context) {
            this.context = context;
            this.commonDialog = CommonDialog.Builder
                    .with(context)
                    .setContentView(R.layout.loading_layout)
                    .setCancelable(false)
                    .setOnKeyListener((dialog, keyCode, event) -> false)
                    .create();
            DYLoadingView dyload = this.commonDialog.findViewById(R.id.dy);
            dyload.start();
        }

        public LoadingDialog create() {
            return new LoadingDialog(this);
        }

    }


}
